package edu.fh.salzburg.its.opsystems.newfs.implementation;


public class NewFSFat {

	private static final long serialVersionUID = 1L;
	public final static int DAMAGED = 0xFF7;
	public final static int LAST = 0xFF8;
	public final static int FREE = 0x000;
	
	public NewFSFat() {
		entry = FREE;
	}
	
	private int entry;
	
	public int getEntry() {
		return this.entry;
	}
	
	public void setEntry(byte[] value) {
		if (value.length != 2) {
			throw new IllegalArgumentException("value is not a FAT Entry");
		}
		this.entry = value[1];
		this.entry |= ((value[0] << 8) & 0x0FFF);
		this.entry = (this.entry < 0) ? this.entry + 256 : this.entry;
	}

	public void setEntry(int value) {
		this.entry = value;
	}
	
	public void setDamaged() {
		this.entry = DAMAGED;
	}
	
	public void setLast() {
		this.entry = LAST;
	}
	
	public void setFree() {
		this.entry = FREE;
	}
	
	public void setUsed(int next) {
		this.entry = next;
	}
	
}
